﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace Td.Additional.Crypt
{
    /// <summary>
    /// String facilities.
    /// </summary>
    public static class String
    {
        /// <summary>
        /// Gets one way hash of given string.
        /// </summary>
        /// <param name="val">The string.</param>
        /// <returns>The one way md5 hash.</returns>
        public static string GetOneWayHash(string val)
        {
            byte[] data = System.Text.ASCIIEncoding.ASCII.GetBytes(val);
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] res = md5.ComputeHash(data);
            return System.Convert.ToBase64String(res, 0, res.Length);
        }
    }
}